﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace comm
{
    public static class FolderHelper
    {
        public static void ClearFolder(string folder)
        {
            var files = Directory.GetFiles(folder);
            foreach (var file in files)
            {
                try
                {
                    File.Delete(file);
                }
                catch (Exception)
                {
                }
            }
            var dirs = Directory.GetDirectories(folder);
            foreach (var d in dirs)
            {
                DeleteFolder(d);
            }
        }

        public static void DeleteFolder(string folder)
        {
            var files = Directory.GetFiles(folder);
            foreach (var file in files)
            {
                try
                {
                    File.Delete(file);
                }
                catch (Exception)
                {
                }
            }
            var dirs = Directory.GetDirectories(folder);
            foreach (var d in dirs)
            {
                DeleteFolder(d);
            }
            try
            {
                Directory.Delete(folder);
            }
            catch (Exception)
            {
            }
        }
    }
}
